package com.huabo.sql.page;

/**
 * Created by Jackie Liu on 2017/6/29.
 */
public class MySQLPage implements PageSql {

    @Override
    public String getSql(String prefixSql, int pageNum, int pageSize) {
        int offset = 0, size = 0, num = 0;
        size = pageSize > 0 ? pageSize : 20;
        num = pageNum > 0 ? pageNum : 1;
        offset = (num - 1) * size;
        return String.format("%s LIMIT %d, %d", prefixSql, offset, size);
    }
}
